<template>
  <div>
    <h1>用户详情页</h1>

    <div class="mainContent">
      <label>用户列表</label>
      <div>
        <label>姓名：</label><strong>{{name}}</strong>
        <label>编号：</label><strong>{{userId}}</strong>
      </div>

    </div>

  </div>
</template>
<script>
export default {
  name: 'info',
  data () {
    return {
      name: '张三',
      userId: 18
    }
  },
  created () {
    this.getInfo()
  },
  methods: {
    getInfo: function () {
      console.info('start request1234565')
      console.info(this.$route)
      const userId = this.$route.query.userId
      console.info(userId)
      var url = '/vueApi/vueUserInfo?userId=' + userId
      console.info(url)
      this.$http.get(url).then(function (res) {
        console.info(res)
        console.info(res.data.user)
        this.name = res.data.user.userName
        this.userId = res.data.user.userId
      }, function () {
        console.info('请求失败！')
      })
    }
  },
  watch: {
    '$router': 'getInfo'
  }
}
</script>
